<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
            function f1(){
                var date = new Date()
                console.log(date);
            }
            
            

            function f2(){
               timerID = setInterval(f1,1000);
               
            }

            function f3(){
                clearInterval(timerID)
                }
            


    </script>
</head>
<body>
    <button onclick="f2()">开始</button>
    <button onclick="f3()">结束</button>
</body>
</html>